package cn.school.controller.dailyWork;

import cn.school.common.api.CommonResult;
import cn.school.dailyWork.service.FaceGateService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @className: FaceGateController
 * @author: Alex
 * @date: 2023/6/1
 **/
@RestController
@RequestMapping("/faceGate")
public class FaceGateController {
	@Autowired
	private FaceGateService faceGateService;
	
	@ApiOperation(value = "receiveFaceGateFlow => 接收人脸门禁流水")
	@PostMapping(value = "/receiveFaceGateFlow")
	public CommonResult<Map<String, String>> receiveFaceGateFlow(@RequestBody List<Map<String,String>> flowList, HttpServletRequest request) throws ParseException {
		if (faceGateService.saveFaceGateFlowList(flowList)) {
			return CommonResult.success();
		}
		return CommonResult.failed();
	}
	
	@ApiOperation(value = "receiveAttendanceRecords => 接收考勤记录")
	@PostMapping(value = "/receiveAttendanceRecords")
	public CommonResult<Map<String, String>> receiveAttendanceRecords(@RequestBody List<Map<String, String>> records) throws ParseException {
		if (faceGateService.saveAttendanceRecords(records)) {
			return CommonResult.success();
		}
		return CommonResult.failed();
	}
	
}
